package com.gary.util;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.binary.Base64;

import java.io.UnsupportedEncodingException;

/**
 * @author peng_rui
 * @date 2022/2/21
 */
@Slf4j
public class Base64Util {

    private static Base64 base64 = new Base64();

    public static String decode(String encodeStr) {
        String decodeStr = null;
        try {
            decodeStr = new String(base64.decode(encodeStr), CONSTANT.UTF8);
        } catch (UnsupportedEncodingException e) {
            log.error("seq = {} 解码失败 error {}", CONSTANT.errorCode, e);
        }
        return decodeStr;
    }

    static class CONSTANT {
        public static final String UTF8 = "utf-8";
        public static final int errorCode = 444;
    }
}
